package com.cslg.webassets.pojo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by rollin on 14/12/9.
 */
public class ResultData<T> {

    private int code;
    private List<String> errors;
    private T data;


    //增加错误信息
    public void addError(String error) {
        code = 1;
        if (errors == null)
            errors = new ArrayList<>();
        errors.add(error);

    }
    //增加多列错误信息
    public void addErrors(List<String> errors) {
        code = 1;
        if (this.errors == null)
            this.errors = new ArrayList<>();
        this.errors.addAll(errors);

    }

    //返回成功信息
    public ResultData success() {
        code = 0;
        return this;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<String> getErrors() {
        return errors;
    }

    public void setErrors(List<String> errors) {
        this.errors = errors;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
